package com.shop.config;


import com.shop.interceptor.LogInterceptor;
import com.shop.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LogInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/static/**");

        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                // 排除jsp
                .excludePathPatterns(
                        "/WEB-INF/jsp/**",
                        "/static/**",
                        "/**/captcha",
                        "/**/captcha/**",
                        "/login", "/register",
                        "/index",
                        "/user/login", "/user/register","/static/**",
                        "/user/upload"
                );
    }
} 